package com.bizmerce.rnd.oms.codemng.service.impl;

import java.util.HashMap;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;

import com.bizmerce.rnd.oms.codemng.service.FtaSearchVO;
import com.bizmerce.rnd.oms.codemng.service.OffshoreVO;

import egovframework.rte.psl.dataaccess.EgovAbstractDAO;

@SuppressWarnings("unchecked")
@Repository("offshoreDAO")
public class OffshoreDAO extends EgovAbstractDAO{
	
	Log log = LogFactory.getLog(OffshoreDAO.class);
	/**
	 * 역외가공기준 - 세번부호 정보가져오기
	 * @param id
	 */
	public List<OffshoreVO> selectOffById(FtaSearchVO searchVO) {
		HashMap<String, String> param = new HashMap<String, String>();
		param.put("AGREE_CD", searchVO.getId());
		param.put("HSCD", searchVO.getHsCode());
		
		int skipResult = (searchVO.getPageIndex() - 1) * searchVO.getPageUnit();
		int maxResult = searchVO.getPageUnit();
		
		return getSqlMapClientTemplate().queryForList("CodeMng.selectOff", param, skipResult, maxResult);
	}
	
	public int selectOffCount(FtaSearchVO searchVO) {
		HashMap<String, String> param = new HashMap<String, String>();
		param.put("AGREE_CD", searchVO.getId());
		param.put("HSCD", searchVO.getHsCode());
		
		if(log.isDebugEnabled()) {
			log.debug("###" + param);
		}
		return (Integer) getSqlMapClientTemplate().queryForObject("CodeMng.selectOffCount", param);
	}
}